package com.tjnmt.togo.listener;

import android.widget.Toast;

import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.route.BikingRouteResult;
import com.baidu.mapapi.search.route.DrivingRouteResult;
import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener;
import com.baidu.mapapi.search.route.TransitRouteResult;
import com.baidu.mapapi.search.route.WalkingRouteResult;
import com.tjnmt.togo.utils.ApplicationUtils;

import org.simple.eventbus.EventBus;

/**
 * 路线规划检索监听者。
 */
public class MyRoutePlanListener implements OnGetRoutePlanResultListener {

    @Override
    public void onGetBikingRouteResult(BikingRouteResult result) {
        if (result.error == SearchResult.ERRORNO.NO_ERROR) {
            EventBus.getDefault().post(result,"tag_search");
        }
        if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
            Toast.makeText(ApplicationUtils.getContext(), "未找到结果,请检查设置", Toast.LENGTH_LONG).show();
        }
        if(result.error == SearchResult.ERRORNO.NETWORK_ERROR){
            Toast.makeText(ApplicationUtils.getContext(),"网络错误,请检查",Toast.LENGTH_LONG).show();
        }
        if(result.error == SearchResult.ERRORNO.NETWORK_TIME_OUT){
            Toast.makeText(ApplicationUtils.getContext(),"网络连接超时",Toast.LENGTH_LONG).show();
        }
        if(result.error == SearchResult.ERRORNO.ST_EN_TOO_NEAR){
            Toast.makeText(ApplicationUtils.getContext(),"起终点太近",Toast.LENGTH_LONG).show();
        }
        if(result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND){
            Toast.makeText(ApplicationUtils.getContext(),"没有找到检索结果",Toast.LENGTH_LONG).show();
        }
        if (result.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
            Toast.makeText(ApplicationUtils.getContext(),"起终点或途经点地址有岐义,请联系后台人员",Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) {

    }

    @Override
    public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) {

    }

    @Override
    public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {

    }
}
